-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[typing] add internal DTypeLike specializations #18194
Conversation
cf6d817
to
6d87bfd
Compare
# Unlike np.typing.DTypeLike, we exclude None, and instead require | ||
# explicit annotations when None is acceptable. | ||
# TODO(jakevdp): consider whether to add ExtendedDtype to the union. | ||
DTypeLike = Union[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it a bad idea to define DTypeLike
as a union of the specialized DTypeLike*
aliases below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DTypeLike
is used in public APIs, so if we change it there's a good chance the perturbation will break the builds of downstream packages. Plus the simplicity here is nice (even if there are invalid strings that it lets through).
I don't think we can merge this: the issue is that these specializations reject valid code if the value of the string input is unknown statically to the type checker. The semantics I want are to allow any generic string in general, BUT if the string value is known statically, it must match one of the known values. As far as I understand, Python's type annotation syntax cannot express that, so accepting any |
No description provided.